home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / gnu / progutil / stdwin.zoo / textedit / textdbg.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-03-30  |  2.3 KB  |  114 lines

  1. /* Text Edit, debugging code */
  2. /* $Header: textdbg.c,v 1.1 88/05/20 16:30:30 guido Locked $ */
  3.  
  4. #include "text.h"
  5.  
  6. #ifndef macintosh
  7.  
  8. /*VARARGS1*/
  9. void dprintf(fmt, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)
  10.     char *fmt;
  11.         int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10;
  12. {
  13.     printf("\r\n");
  14.     printf(fmt, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
  15.     printf("\r\n");
  16. }
  17.  
  18. #endif
  19.  
  20. #ifndef NDEBUG
  21.  
  22. /* Check the world's consistency */
  23.  
  24. techeck(tp, line)
  25.     TEXTEDIT *tp;
  26.     int line;
  27. {
  28.     lineno i;
  29.  
  30. #define zck(n) ((n) || dprintf("zck(n) line %d", line))
  31.     
  32.     zck(tp->nlines >= 1);
  33.     
  34.     zck(tp->start[0] == zaddgap(0));
  35.     zck(tp->start[tp->nlines] == tp->buflen);
  36.     
  37.     zck(0 <= tp->gap);
  38.     zck(0 <= tp->gaplen);
  39.     zck(zgapend <= tp->buflen);
  40.     
  41.     zck(0 <= tp->foc);
  42.     zck(0 <= tp->foclen);
  43.     zck(zfocend <= tp->buflen-tp->gaplen);
  44.     
  45.     for (i= 0; i < tp->nlines; ++i) {
  46.         if (i < tp->nlines-1)
  47.             { zck(tp->start[i] < tp->start[i+1]); }
  48.         else
  49.             { zck(tp->start[i] <= tp->start[tp->nlines]); }
  50.         zck(tp->start[i] < tp->gap || zgapend <= tp->start[i]);
  51.     }
  52.  
  53. #undef zck
  54.  
  55. }
  56.  
  57. #if 0
  58.  
  59. /* Dump the world's state to the screen (call from drawproc) */
  60.  
  61. zdebug(left, top, right, bottom)
  62. {
  63.     int h, v;
  64.     int i, j;
  65.     
  66.     h= 0, v= 15*wlh; if (v >= bottom) return;
  67.     zprintf(h, v, "buflen=%d nlines=%d foc=%d foclen=%d gap=%d gaplen=%d.",
  68.         buflen, nlines, foc, foclen, gap, gaplen);
  69.     h= 0, v += wlh; if (v >= bottom) return;
  70.     for (i= 0; i <= nlines; ++i) {
  71.         h= zprintf(h, v, "%d:%d ", i, start[i]);
  72.     }
  73.     h= 0, v += wlh; if (v >= bottom) return;
  74.     for (i= 0; i <= buflen; ++i) {
  75.         h= zprintf(h, v, "%c",
  76.             i == zaddgap(foc) ?
  77.                 (foclen == 0 ? '|' : '[') :
  78.                 (i == zaddgap(focend) ? ']' : ' '));
  79.         if (i >= buflen)
  80.             break;
  81.         if (i >= gap && i < gapend)
  82.             h= zprintf(h, v, "**");
  83.         else
  84.             h= zprintf(h, v, "%02x", buf[i] & 0xff);
  85.     }
  86.     h= 0, v += wlh; if (v >= bottom) return;
  87.     for (i= 0; i <= buflen; ++i) {
  88.         for (j= 0; j <= nlines; ++j)
  89.             if (i == start[j])
  90.                 break;
  91.         if (j <= nlines)
  92.             h= zprintf(h, v, "%-3d", j);
  93.         else
  94.             h= zprintf(h, v, "   ");
  95.     }
  96. }
  97.  
  98. /* Printf into the window (could be of general use).
  99.    NB: doesn't recognize \n */
  100.  
  101. static
  102. zprintf(h, v, fmt, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)
  103.     int h, v;
  104.     char *fmt;
  105. {
  106.     char buf[256];
  107.     sprintf(buf, fmt, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
  108.     return wdrawtext(h, v, buf, -1);
  109. }
  110.  
  111. #endif
  112.  
  113. #endif /* !NDEBUG */
  114.